<?php
/*
 * Favor tener cuidado con la siguiente ruta. Si ingresa este archivo dentro de una carpeta en
 * el framework, es necesario agregar ../ al comienzo de la ruta.
 */
require('../configs/include.php');

/*
 * Clase crear historia (historia)
 */

class c_movimiento extends super_controller {
    
    public function registrar(){
        $movimiento = new movimiento($this->post);
        $options = "normal";

        $this->orm->connect();
        $this->orm->insert_data($options, $movimiento);
        $this->orm->close();

        $this->img_warning = "correct.png";
        $this->type_warning = "success";
        $this->msg_warning = "El movimiento ha sido registrada satisfatoriamente";
        $this->engine->assign('type_warning', $this->type_warning);
        $this->engine->assign('msg_warning', $this->msg_warning);
        $this->temp_aux = 'message.tpl';
    }
    
    
    public function display() {
        $this->engine->assign('title', 'Capturar Movimiento');
        $this->engine->display('header.tpl');

         
        if ($this->error == 1) {
            $this->engine->assign('obj', $this->post);
            $this->engine->assign('type_warning', $this->type_warning);
            $this->engine->assign('msg_warning', $this->msg_warning);
            $this->temp_aux = 'message.tpl';
        }
        $this->engine->display($this->temp_aux);
        $this->engine->display('capturar_movimiento.tpl');
        $this->engine->display('footer.tpl');   
    }

    public function run() {
       try {
            if (isset($this->get->option)) {
                $this->{$this->get->option}();
            }
        } catch (Exception $e) {
            $this->error = 1;
            $this->img_warning = 'incorrect.png';
            $this->msg_warning = $e->getMessage();
        }
        $this->display();
    }

}

$call = new c_movimiento();
$call->run();
?>
